package com.ruoyi.project.system.controller;

import java.util.List;

import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.domain.StudentCourseQuestion;
import com.ruoyi.project.system.service.IStudentCourseQuestionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 学生课程练习Controller
 * 
 * @author ruoyi
 * @date 2020-10-07
 */
@RestController
@RequestMapping("/system/studentCourseQuestion")
public class StudentCourseQuestionController extends BaseController
{
    @Autowired
    private IStudentCourseQuestionService studentCourseQuestionService;

    /**
     * 查询学生课程练习列表
     */
    @PreAuthorize("@ss.hasPermi('system:question:list')")
    @GetMapping("/list")
    public TableDataInfo list(StudentCourseQuestion studentCourseQuestion)
    {
        startPage();
        List<StudentCourseQuestion> list = studentCourseQuestionService.selectStudentCourseQuestionList(studentCourseQuestion);
        return getDataTable(list);
    }

    /**
     * 导出学生课程练习列表
     */
    @PreAuthorize("@ss.hasPermi('system:question:export')")
    @Log(title = "学生课程练习", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StudentCourseQuestion studentCourseQuestion)
    {
        List<StudentCourseQuestion> list = studentCourseQuestionService.selectStudentCourseQuestionList(studentCourseQuestion);
        ExcelUtil<StudentCourseQuestion> util = new ExcelUtil<StudentCourseQuestion>(StudentCourseQuestion.class);
        return util.exportExcel(list, "question");
    }

    /**
     * 获取学生课程练习详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:question:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(studentCourseQuestionService.selectStudentCourseQuestionById(id));
    }

    /**
     * 新增学生课程练习
     */
    @Log(title = "学生课程练习", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StudentCourseQuestion studentCourseQuestion)
    {
        return toAjax(studentCourseQuestionService.insertStudentCourseQuestion(studentCourseQuestion));
    }

    /**
     * 修改学生课程练习
     */
    @PreAuthorize("@ss.hasPermi('system:question:edit')")
    @Log(title = "学生课程练习", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StudentCourseQuestion studentCourseQuestion)
    {
        return toAjax(studentCourseQuestionService.updateStudentCourseQuestion(studentCourseQuestion));
    }

    /**
     * 删除学生课程练习
     */
    @PreAuthorize("@ss.hasPermi('system:question:remove')")
    @Log(title = "学生课程练习", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(studentCourseQuestionService.deleteStudentCourseQuestionByIds(ids));
    }
}
